package com.uzipi.springcloud.eurekaconsumerfeign.controller;

import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>name：UploadService </p>
 * <p>description: [类型描述] </p>
 *
 * @author uzipi
 * @version v1.0
 * @since
 */
@FeignClient(value = "upload-server", configuration = UploadService.MultipartSupportConfig.class)
@Service("uploadService")
public interface UploadService {

    @Configuration
    class MultipartSupportConfig {
        @Bean
        public SpringFormEncoder feignFormEncoder() {
            return new SpringFormEncoder();
        }
    }

    @PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String handleFileUpload(@RequestPart(value = "file") MultipartFile file);
}
